package me.ZFC.Text;

import java.util.Scanner;

public class Test12 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个字符串");
        while (true) {
            String s = sc.next();
            boolean flag = check(s);
            if (flag) {
                break;
            } else {
                System.out.println("请重新输入");
            }
        }
    }

    public static boolean check(String str) {
        if (str.length() > 9) {
            return false;
        }
        for (int i = 0; i < str.length(); i++) {
            if (!Character.isDigit(str.charAt(i))) {
                return false;
            }
        }
        return true;
    }
}
